import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";

Vue.use(VueRouter);

const routes = [
  //首页
  {
    path: "/",
    name: "home",
    component: Home,
  },
  //登录页面
  {
    path: "/login",
    name: "login",
    component: () => import("../components/Login.vue"),
  },
  //注册页面
  {
    path: "/regist",
    name: "regist",
    component: () => import("../components/Regist.vue"),
  },
  //目的地页面
  {
    path: "/destination",
    name: "destination",
    component: () => import("../views/Destination.vue"),
  },
  //目的地详情页面
  {
    path: "/destination/detail",
    name: "destinationDetail",
    component: () => import("../components/DestinationDetail.vue"),
  },
  //旅游攻略页面
  {
    path: "/strategy",
    name: "strategy",
    component: () => import("../views/Strategy.vue"),
  },
  //旅游攻略详情页面
  {
    path: "/strategy/detail",
    name: "strategyDetail",
    component: () => import("../components/StrategyDetail.vue"),
  },
  //旅游日记页面
  {
    path: "/travel",
    name: "travel",
    component: () => import("../views/Travel.vue"),
  },
   //旅游日记详情页面
   {
    path: "/travel/detail",
    name: "travelDetail",
    component: () => import("../components/TravelDetail.vue"),
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});
// 把这段代码直接粘贴到router/index.js中的Vue.use(VueRouter)之前
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function (location) {
  return originalPush.call(this, location).catch((err) => {});
};

export default router;
